﻿namespace RandomGames
{
    internal class Program
    {
        const int TestTime = 10;//设定循环次数
        static void Main(string[] args)
        {
            int n = 0;//出错次数为0
            DateTime start=DateTime.Now;    
            for(int i = 1; i <= TestTime; i++)
            {
                Console.Clear();
                Console.WriteLine("现在是第" + i + "次实验");
                Random a= new Random();//计算机随机输入
                char x=(char)a.Next(65,90);//强制转换
                Console.WriteLine(x);//输出
                bool flag = true;
                do
                {
                    char input=Console.ReadKey().KeyChar;//输入字符
                    if (input == x)
                        break;
                    else n++;//出错次数加1
                }while(flag==false);
                Console.Clear();//最后清空屏幕

                DateTime end=DateTime.Now;
                TimeSpan time = end - start;
                Console.WriteLine($"总耗时：{time.TotalMilliseconds}ms");
                Console.WriteLine("错误次数" + n + "次");





            }
        }
    }
}